<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Alterar Calendarios</title>
        <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <script type="text/javascript" src="../js/jquery.ui.datepicker-pt-BR.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <link rel="stylesheet" href="../css/forms.css">
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">

    </head>
    <script>$(document).ready(function(){
        $("#data_calendario").datepicker();
        $("#form").validate({
            rules: {
                data_calendario: {required: true}
                ,id_unidade: {digits: true
                }
                ,desc_calendario: {required: true}
                ,diautil_calendario: {required: true}
            },
            submitHandler: function(form) {
                salvar(form);
            }
        });
    });
    </script>


    <body>
        <form name="form" id="form" method="post" action="update.jsp" >
            <fieldset><legend>Dados</legend>
                <fmt:parseDate value="${param.data}" var="data" pattern="dd/MM/yyyy"/>
                <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                    SELECT  * FROM Calendarios where id_calendario=?
                    <sql:param value="${param.chave}"/>
                </sql:query>
                <c:forEach var="row" items="${query.rows}">
                    <fmt:formatDate value="${row.data_calendario}" var="data" pattern="dd/MM/yyyy"/>
                    <input type="hidden" name="id_calendario" value="${row.id_calendario}">

                    <p><label class="lbInput">Data<em>*</em></label>
                        <input type="text" id="data_calendario" name="data_calendario" size="10" maxlength="10" class="required"
                               value="${data}">
                    </p>
                    <p><label class="lbInput">Cidade<em>*</em></label>
                        <sql:query var="queryCidade" dataSource="jdbc/dbo_MicrosoftSQLServer">
                            SELECT  * FROM Cidades
                            order by nome_cidade
                        </sql:query>
                        <select name="id_cidade" class="required">
                            <option value="0">Todas</option>
                            <c:forEach var="cidade" items="${queryCidade.rows}">
                                <option value="${cidade.id_cidade}" ${cidade.id_cidade==row.id_cidade?'selected':''}>${cidade.nome_cidade}</option>
                            </c:forEach>
                        </select>
                    </p>
                    <p><label class="lbInput">Descrição<em>*</em></label>
                        <input type="text" name="desc_calendario" size="50" maxlength="50" class="required" value="${row.desc_calendario}">
                    </p>
                    <p><label class="lbInput">Dia útil?<em>*</em></label>
                        <select name="diautil_calendario" class="required">
                            <option value="S" ${row.diautil_calendario=='S'?'selected':''}>Sim</option>
                            <option value="N" ${row.diautil_calendario=='N'?'selected':''}>Não</option>

                        </select>                      
                    </p>
                </c:forEach>

                <p>
                    <input class="submit" type="submit" value="Salvar">
                    <input class="submit" type="button" value="Remover" onclick="remover(document.forms[0])" style="visibility:visible">
                </p>
                <div id="ajax_dados" style="display:block">
                </div>
                <div id="msg" style="display:none"></div>
            </fieldset>
        <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
    </body>
</html>
